const db = require("../../config/db");

module.exports = {
    getNews() {
        return new Promise((resolve, reject) => {
            let get_news_sql = `select * from db_news limit 0,20`;
            db.query(get_news_sql, (err, rows) => {
                if (err) {
                    reject(err);
                } else {
                    resolve(rows);
                }
            });
        });
    },
    getTodayLook({ news_type }) {
        return new Promise((reslove, reject) => {
            let get_todaylook_sql = `select * from db_news where category="${news_type}" limit 0,20;`;
            db.query(get_todaylook_sql, (err, rows) => {
                if (err) {
                    reject(err);
                } else {
                    reslove(rows);
                }
            });
        });
    },
};
